<script src="__PUBLIC__/ganged/Js/city-picker.data.js"></script>
<script src="__PUBLIC__/ganged/Js/city-picker.js"></script>
<script src="__PUBLIC__/ganged/Js/main.js"></script>
<!-- css -->
<link href="__PUBLIC__/ganged/Css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/ganged/Css/city-picker.css" rel="stylesheet" type="text/css" />

<div class="container" style="padding-top: 50px;">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <form class="form-horizontal" role="form" id="post_form" action="{:U('')}">
                <div class="form-group">
                    <label for="name" class="col-sm-2 control-label">名称:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="name" id="name"/>
                    </div>
                </div>
                <div class="form-group">
                    <label for="dif" class="col-sm-2 control-label">差价:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="dif" id="dif" value="0" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="num" class="col-sm-2 control-label">库存:<span style="color: red;">*</span></label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" name="num" id="num" value="0" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-primary" id="btn" lng="0" lat="0">提交</button>
                    </div>
                </div>
                <input type="hidden" name="goods_id" value="{$goods_id}">
            </form>
        </div>
</div>
<script>
$(function(){
    $("#btn").click(function(){
            var $form = $("#post_form");
            var $data = {};
            var $form_data = $form.serializeArray();
            $.each($form_data, function(k, v){
                $data[v['name']] = v['value'];
            })
            $.post($form.attr('action'), $data, function(obj){
                alert(obj.m);
                if(obj.s){
                    if(typeof(obj.url)!= "undefined" && obj.url){
                        location.href = obj.url;
                    }
                }
            })
            return false;
        })
    });
</script>
